{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\LT-054912\surfdrive\Diffusion\dataverse files\Stata commands to replicate figure 5.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}29 Aug 2023, 15:31:07
{txt}
{com}. 
. **Get learning pathway scores
. 
. preserve
{txt}
{com}. 
. use "pathway scores h4.dta", clear
{txt}
{com}. 
. keep if family_dynamic1=="Radical Right Populists"
{txt}(53,170 observations deleted)

{com}. 
. bys country_ipol: egen max_path=max(pathways1)
{txt}
{com}. 
. rename pathways1 pathways1_h4 
{res}{txt}
{com}. rename max_path max_path_h4
{res}{txt}
{com}. 
. save "Radical Right Populists_learn_pathway.dta", replace
{txt}{p 0 4 2}
(file {bf}
Radical Right Populists_learn_pathway.dta{rm}
not found)
{p_end}
{p 0 4 2}
file {bf}
Radical Right Populists_learn_pathway.dta{rm}
saved
{p_end}

{com}. 
. restore
{txt}
{com}. 
. use "dataset for analysis.dta", clear
{txt}
{com}. 
. keep if family_dynamic1=="Radical Right Populists"
{txt}(53,170 observations deleted)

{com}. 
. sort family_dynamic1 country_ipol elec_year
{txt}
{com}. merge family_dynamic1 country_ipol elec_year using "pathway scores h1.dta", sort
{txt}{p}
(you are using old
{bf:merge} syntax; see
{bf:{help merge:[D] merge}} for new syntax)
{p_end}

{com}. drop if _merge==2
{txt}(53,170 observations deleted)

{com}. drop _merge
{txt}
{com}. 
. keep country_ipol elec_year wx_lag_votperfor_ipol family_dynamic1 totentry2 totentry2_ipol pathways1 lag_totentry2_ipol lag_votperfor_ipol votperfor_ipol pathways1
{txt}
{com}. 
. sort family_dynamic1 country_ipol elec_year
{txt}
{com}. merge family_dynamic1 country_ipol elec_year using "Radical Right Populists_learn_pathway.dta", sort
{txt}{p}
(you are using old
{bf:merge} syntax; see
{bf:{help merge:[D] merge}} for new syntax)
{p_end}

{com}. drop if _merge==2
{txt}(0 observations deleted)

{com}. drop _merge
{txt}
{com}. 
. **H1
. 
. bys country_ipol: egen max_path_h1=max(pathways1)
{txt}
{com}. bys country_ipol: tab elec_year if pathways1==max_path_h1

{txt}{hline}
-> country_ipol = Austria

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Belgium

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2013 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Denmark

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Finland

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = France

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Germany

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2008 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Greece

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Ireland

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Italy

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2008 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Luxembourg

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Netherlands

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Norway

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Portugal

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Spain

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2016 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Sweden

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Switzerland

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2013 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = United Kingdom

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2015 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}
{com}. bys country_ipol: tab pathways1 if pathways1==max_path_h1

{txt}{hline}
-> country_ipol = Austria

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0430462 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Belgium

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0324409 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Denmark

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
     .04383 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Finland

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0591958 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = France

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0412521 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Germany

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0330522 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Greece

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0432045 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Ireland

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0449605 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Italy

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0202861 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Luxembourg

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0443055 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Netherlands

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0444463 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Norway

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0405559 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Portugal

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0410786 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Spain

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
    .036488 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Sweden

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0346366 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Switzerland

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0387655 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = United Kingdom

  pathways1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0420361 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}
{com}. 
. bys country_ipol: egen max_path_event_h1=max(pathways1) if totentry2_ipol!=0
{txt}(806 missing values generated)

{com}. bys country_ipol: egen max_path_event_h1_v2=max(max_path_event_h1)
{txt}
{com}. 
. drop max_path_event_h1
{txt}
{com}. rename max_path_event_h1_v2 max_path_event_h1
{res}{txt}
{com}. 
. bys country_ipol: egen max_path_event_noimp_h1=max(pathways1) if totentry2!=0 & totentry2!=.
{txt}(806 missing values generated)

{com}. bys country_ipol: egen max_path_event_noimp_h1_v2=max(max_path_event_noimp_h1)
{txt}
{com}. 
. drop max_path_event_noimp_h1
{txt}
{com}. rename max_path_event_noimp_h1_v2 max_path_event_noimp_h1
{res}{txt}
{com}. 
. **H4
. 
. bys country_ipol: egen max_path_event_h4=max(pathways1_h4) if totentry2_ipol!=0
{txt}(806 missing values generated)

{com}. bys country_ipol: egen max_path_event_h4_v2=max(max_path_event_h4)
{txt}
{com}. 
. drop max_path_event_h4
{txt}
{com}. rename max_path_event_h4_v2 max_path_event_h4
{res}{txt}
{com}. 
. bys country_ipol: egen max_path_event_noimp_h4=max(pathways1_h4) if totentry2!=0 & totentry2!=.
{txt}(806 missing values generated)

{com}. bys country_ipol: egen max_path_event_noimp_h4_v2=max(max_path_event_noimp_h4)
{txt}
{com}. 
. drop max_path_event_noimp_h4
{txt}
{com}. rename max_path_event_noimp_h4_v2 max_path_event_noimp_h4
{res}{txt}
{com}. 
. bys family_dynamic1 elec_year: egen wy_lag_totentry2_ipol=sum(lag_totentry2_ipol)
{txt}
{com}. replace wy_lag_totentry2_ipol=wy_lag_totentry2_ipol-lag_totentry2_ipol
{txt}(128 real changes made)

{com}. 
. bys country: tab max_path_event_h1

{txt}{hline}
-> country_ipol = Austria

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0145013 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Belgium

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0077701 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Denmark

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
    .009499 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Finland

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0174713 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = France

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0189248 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Germany

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0330522 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Greece

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0198981 {c |}{res}         40      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         40      100.00

{txt}{hline}
-> country_ipol = Ireland

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
  -.0337569 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Italy

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0202861 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Luxembourg

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0270364 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Netherlands

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0264795 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Norway

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0190585 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Portugal

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0180897 {c |}{res}         41      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         41      100.00

{txt}{hline}
-> country_ipol = Spain

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0195735 {c |}{res}         38      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         38      100.00

{txt}{hline}
-> country_ipol = Sweden

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0098397 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = Switzerland

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0341364 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}{hline}
-> country_ipol = United Kingdom

max_path_ev {c |}
     ent_h1 {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0271336 {c |}{res}         59      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         59      100.00

{txt}
{com}. bys country: tab elec_year if max_path_event_h1==pathways1

{txt}{hline}
-> country_ipol = Austria

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2006 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Belgium

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       1997 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Denmark

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2000 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Finland

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2011 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = France

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2005 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Germany

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2008 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Greece

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2005 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Ireland

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2016 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Italy

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2008 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Luxembourg

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2008 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Netherlands

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2008 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Norway

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2008 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Portugal

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2004 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Spain

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2002 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Sweden

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2000 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = Switzerland

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2008 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}{hline}
-> country_ipol = United Kingdom

   Election {c |}
       year {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2008 {c |}{res}          1      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}          1      100.00

{txt}
{com}. 
. bys elec_year: egen famentry=sum(totentry2_ipol)
{txt}
{com}. bys elec_year: egen famentrylag=sum(lag_totentry2_ipol) 
{txt}
{com}. bys elec_year: egen famvotlag=sum(lag_votperfor_ipol) 
{txt}
{com}. bys elec_year: egen famvot=sum(votperfor_ipol)
{txt}
{com}. bys elec_year: egen mean_path=mean(pathways1) 
{txt}(42 missing values generated)

{com}. bys elec_year: egen famentry_noimp=sum(totentry2)
{txt}
{com}. 
. gen votperfor=votperfor
{txt}
{com}. replace votperfor=. if totentry2==.
{txt}(0 real changes made)

{com}. 
. bys elec_year: egen famvot_noimp=sum(votperfor)
{txt}
{com}. 
. rename pathways1 path_h1
{res}{txt}
{com}. rename pathways1_h4 path_h4
{res}{txt}
{com}. 
. **Here we implement that pathway scores are only used in years where the family entered in the focal country
. replace path_h1=. if totentry2_ipol==0
{txt}(702 real changes made, 702 to missing)

{com}. replace path_h4=. if totentry2_ipol==0
{txt}(702 real changes made, 702 to missing)

{com}. 
. gen elec_year2=elec_year+0.4
{txt}
{com}. 
. **Median pathway score
. 
. bys elec_year: egen med_path_h1=median(path_h1)
{txt}(289 missing values generated)

{com}. bys elec_year: egen med_path_h4=median(path_h4)
{txt}(289 missing values generated)

{com}. 
. twoway bar med_path_h1 elec_year, barwidth(0.3) col(black)  ///
> || bar med_path_h4 elec_year2, barwidth(0.3) col(gs10) yline(0) ///
> ytitle("Pathway median score") xla(1960(5)2020) ///
> legend(order(1 "Median pathway score emulation" 2 "Median pathway score learning")  pos(6)) ///
> scheme(plottig)  name(e, replace) 
{res}{txt}
{com}. 
. **Standardized entry
. 
. egen std_famentry=std(famentry)
{txt}
{com}. egen std_famvot=std(famvot)
{txt}
{com}. 
. sort country elec_year
{txt}
{com}. twoway line std_famentry  elec_year if country_ipol=="France" ,  lcolor(black)  ///
> || line std_famvot elec_year if country_ipol=="France", lcolor(gs10)   ///
> ytitle("Standardized values") ///
> yla(-2 "-2  " -1 "-1  " 0 "0  " 1 "1  " 2 "2  " 3 "3  " ) ///
> xtitle("") xla(1960(5)2020) scheme(plottig) legend(order(1 "Party family entry (most recent election)" 2 "Vote share of party family (most recent election)")  pos(6)) name(a, replace)
{res}{txt}
{com}. 
. graph combine a e, scheme(plottig) col(1)
{res}{txt}
{com}. graph export "Figure5.tif", replace
{txt}{p 0 4 2}
(file {bf}
Figure5.tif{rm}
not found)
{p_end}
{p 0 4 2}
file {bf}
Figure5.tif{rm}
saved as
TIFF
format
{p_end}

{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\LT-054912\surfdrive\Diffusion\dataverse files\Stata commands to replicate figure 5.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}29 Aug 2023, 15:31:12
{txt}{.-}
{smcl}
{txt}{sf}{ul off}